home *** CD-ROM | disk | FTP | other *** search
/ Precision Software Appli…tions Silver Collection 4 / Precision Software Applications Silver Collection Volume 4 (1993).iso / database / sr_info.exe / FILTERCR.PRG < prev    next >
Text File  |  1990-04-11  |  2KB  |  73 lines

  1. **************************************************************************
  2. **  FILTER.PRG ***
  3. **  (C) Copyright 1990, Sub Rosa Publishing Inc.
  4. **  A demonstration program provided to SR-Info and VP-Info users.
  5. **  This program may be copied freely. If it is used in commercial code,
  6. **  please credit the source, Sub Rosa Publishing Inc.
  7. **
  8. **  FILTERCR demonstrates the use of sequential file functions to produce
  9. **  an altered copy of given file.
  10. **  FILTERCR is compatible with all current versions of SR-Info and VP-Info.
  11. **
  12. **  FILTERCR provides a facility not usually available on text editors.
  13. **  It replaces a selected character in a file with a carrige return and
  14. **  a line feed. One use of this program is to replace a long list
  15. **  of comma-separated items (as in a 'C' program) with a list presenting
  16. **  one item per line.
  17. **
  18. **  Bernie Melman and Sid Bursten
  19. **  April 1,1990
  20. ***************************************************************************
  21. SET raw on ; no extra space between print fields
  22. * initialize variables
  23. infile=blank(12)
  24. outfile=blank(12)
  25. key_char=' '
  26. inp_char=' '
  27. WINDOW ; get rid on any window left open.
  28. ERASE ; clear screen
  29. * set up input screen - note that all variables used have been initialized
  30. * .. lines are picture clauses forcing upper case for infile and outfile
  31. TEXT
  32. .. infile  !!!!!!!!!!!!
  33. .. outfile !!!!!!!!!!!!
  34.  
  35.                          INPUT FILE: @infile
  36.  
  37.                         OUTPUT FILE: @outfile
  38.  
  39. Substitute CR/LF for this character: @key_char
  40. ENDTEXT
  41. READ                                                  
  42. *; get rid of old output
  43. DELETE file &outfile ; note if file name has no extension, include '.' in name
  44. ?
  45. IF ropen(infile); don't even try if files won't open!
  46.    IF wopen(outfile,2)
  47.       ? ;start new line
  48.       DO WHILE in(inp_char); start of main loop
  49.          ?? inp_char;  echo characters to screen
  50.          IF inp_char <> key_char
  51.             ok= OUT(inp_char,2)
  52.          ELSE
  53.             ok= out(chr(13),2)
  54.             ok= out(chr(10),2)
  55.          ENDIF 
  56.       ENDDO ; end of main loop
  57. * close files
  58.       IF .not. close(1)
  59.          ? "Problem closeing file :"+infile
  60.       ENDIF
  61.       IF .not. close(2)
  62.          ? "Problem closing output file :"+outfile
  63.       ENDIF
  64. * done
  65.    ELSE
  66.       ? "Unable to open output file :"+outfile
  67.    ENDIF
  68. ELSE
  69.    ? "Unable to open input file :"+infile
  70. ENDIF
  71. *
  72. *                    *** end of FILTERCR.PRG ***
  73.